package com.casstime.ec.cloud.meeting.service.handler;

import com.casstime.ec.cloud.meeting.dao.entity.EntityDevice;
import com.casstime.ec.cloud.meeting.dao.entity.example.EntityDeviceExample;
import com.casstime.ec.cloud.meeting.dao.mapper.EntityDeviceMapper;
import com.casstime.ec.cloud.meeting.model.Device;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 会议室设备处理
 * @author  罗茜
 */
@Service
public class DeviceHandler {

  @Autowired
  private EntityDeviceMapper entityDeviceMapper;


  /**
   * 查询某个会议室的设备情况
   * @param roomId
   * @return
   */
  public List<Device> getEquipByRoomId(Integer roomId) {
    List<Device> deviceList = new ArrayList<Device>();
    EntityDeviceExample entityDeviceExample = new EntityDeviceExample();
    entityDeviceExample.createCriteria().andRoomIdEqualTo(roomId);
    List<EntityDevice> entityDeviceList = entityDeviceMapper.selectByExample(entityDeviceExample);
    if(entityDeviceList.size() == 0) {
        return null;
    }
    for(EntityDevice entityDevice : entityDeviceList) {
        deviceList.add(Device.get(entityDevice));
    }
    return deviceList;
  }


}
